<!--#include file="Librerias/mssql-ds.dll" -->
<%
'// Recuperar la gestion de trabajo
qGestion = Session("auth_granted_poa_gestion")

if Len(varApertura) = 0 Then
  sSQL = ""
  sSQL = sSQL & " SELECT TOP 1 aper_programa"
  sSQL = sSQL & " FROM AperturaProgramatica"
  sSQL = sSQL & " WHERE  (Len(aper_programa) = 2) AND (aper_proyecto = '0000') AND (aper_actividad = '000') AND (aper_gestion = "& qGestion &")"
  MatrizTempo = MatrixBD(sSQL, 1)
  If VarType(MatrizTempo) = 8  then
    QTempo = -1
  Else
    QTempo = UBound(MatrizTempo,2)	
  End If
  If QTempo > -1 Then
    varApertura = MatrizTempo(0,0)
  End If
End If
sSQL = ""
sSQL = sSQL & " SELECT aper_id, aper_programa, aper_proyecto, aper_actividad, aper_descripcion, aper_ponderacion"
sSQL = sSQL & " FROM AperturaProgramatica"
sSQL = sSQL & " WHERE (Len(aper_programa) = 2) AND (aper_proyecto = '0000') AND (aper_actividad = '000') AND (aper_gestion = "& qGestion &")"
MatrizPrograma = MatrixBD(sSQL, 1)
If VarType(MatrizPrograma) = 8  then
  QPrograma = -1
Else
  QPrograma = UBound(MatrizPrograma,2)	
End If

BigUltimateGranSumPA1p = 0
BigUltimateGranSumPA2p = 0
BigUltimateGranSumPA3p = 0
BigUltimateGranSumPA4p = 0
BigUltimateGranSumPA5p = 0
BigUltimateGranSumPA6p = 0
BigUltimateGranSumPA7p = 0
BigUltimateGranSumPA8p = 0
BigUltimateGranSumPA9p = 0
BigUltimateGranSumPA10p = 0
BigUltimateGranSumPA11p = 0
BigUltimateGranSumPA12p = 0

BigUltimateGranSumEA1p = 0
BigUltimateGranSumEA2p = 0
BigUltimateGranSumEA3p = 0
BigUltimateGranSumEA4p = 0
BigUltimateGranSumEA5p = 0
BigUltimateGranSumEA6p = 0
BigUltimateGranSumEA7p = 0
BigUltimateGranSumEA8p = 0
BigUltimateGranSumEA9p = 0
BigUltimateGranSumEA10p = 0
BigUltimateGranSumEA11p = 0
BigUltimateGranSumEA12p = 0

for x = 0 to QPrograma 
  sSQL = ""
  sSQL = sSQL & " SELECT aper_id, aper_programa, aper_proyecto, aper_actividad, aper_descripcion, aper_ponderacion"
  sSQL = sSQL & " FROM AperturaProgramatica"
  sSQL = sSQL & " WHERE (aper_estado = 1) AND (aper_gestion = "& qGestion &")"
  sSQL = sSQL & " AND (Len(aper_programa) = 2 AND aper_programa = '"& MatrizPrograma(1,x) &"') AND ((aper_proyecto <> '0000') OR (aper_actividad <> '000'))"
  MatrizApertura = MatrixBD(sSQL, 1)
  If VarType(MatrizApertura) = 8  then
    NumeroRegistros = -1
  Else
    NumeroRegistros = UBound(MatrizApertura,2)	
  End If
  UltimateGranSumPA1p = 0
  UltimateGranSumPA2p = 0
  UltimateGranSumPA3p = 0
  UltimateGranSumPA4p = 0
  UltimateGranSumPA5p = 0
  UltimateGranSumPA6p = 0
  UltimateGranSumPA7p = 0
  UltimateGranSumPA8p = 0
  UltimateGranSumPA9p = 0
  UltimateGranSumPA10p = 0
  UltimateGranSumPA11p = 0
  UltimateGranSumPA12p = 0
  
  UltimateGranSumEA1p = 0
  UltimateGranSumEA2p = 0
  UltimateGranSumEA3p = 0
  UltimateGranSumEA4p = 0
  UltimateGranSumEA5p = 0
  UltimateGranSumEA6p = 0
  UltimateGranSumEA7p = 0
  UltimateGranSumEA8p = 0
  UltimateGranSumEA9p = 0
  UltimateGranSumEA10p = 0
  UltimateGranSumEA11p = 0
  UltimateGranSumEA12p = 0
    
  For k = 0 To NumeroRegistros 
        GranSumPA1p = 0
    GranSumPA2p = 0
    GranSumPA3p = 0
    GranSumPA4p = 0
    GranSumPA5p = 0
    GranSumPA6p = 0
    GranSumPA7p = 0
    GranSumPA8p = 0
    GranSumPA9p = 0
    GranSumPA10p = 0
    GranSumPA11p = 0
    GranSumPA12p = 0
    
    GranSumEA1p = 0
    GranSumEA2p = 0
    GranSumEA3p = 0
    GranSumEA4p = 0
    GranSumEA5p = 0
    GranSumEA6p = 0
    GranSumEA7p = 0
    GranSumEA8p = 0
    GranSumEA9p = 0
    GranSumEA10p = 0
    GranSumEA11p = 0
    GranSumEA12p = 0
    
        sSQL = ""
    sSQL = sSQL & " SELECT Procesos"& qGestion &".pro"& qGestion &"_id, Procesos"& qGestion &".pesp"& qGestion &"_id, Procesos"& qGestion &".pro"& qGestion &"_codigo,"
    sSQL = sSQL & " Procesos"& qGestion &".pro"& qGestion &"_proceso, Procesos"& qGestion &".pro"& qGestion &"_objetivo, Procesos"& qGestion &".indi_id,"
    sSQL = sSQL & " Procesos"& qGestion &".pro"& qGestion &"_indicador, Procesos"& qGestion &".pro"& qGestion &"_formula,"
    sSQL = sSQL & " Procesos"& qGestion &".pro"& qGestion &"_linea_base, Procesos"& qGestion &".pro"& qGestion &"_meta,"
    sSQL = sSQL & " Procesos"& qGestion &".pro"& qGestion &"_fuente_verificacion, Procesos"& qGestion &".pro"& qGestion &"_metodo,"
    sSQL = sSQL & " Procesos"& qGestion &".pro"& qGestion &"_tendencia, Procesos"& qGestion &".pro"& qGestion &"_supuestos,"
    sSQL = sSQL & " Procesos"& qGestion &".pro"& qGestion &"_presupuesto, Procesos"& qGestion &".pro"& qGestion &"_ponderacion,"
    sSQL = sSQL & " Procesos"& qGestion &".pro"& qGestion &"_cargo, Procesos"& qGestion &".pro"& qGestion &"_responsable, Procesos"& qGestion &".uni_id,"
    
    ' absoluto PROG
    ' pos : 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30
    sSQL = sSQL & " Procesos"& qGestion &".pro"& qGestion &"_1P, Procesos"& qGestion &".pro"& qGestion &"_2P, Procesos"& qGestion &".pro"& qGestion &"_3P, Procesos"& qGestion &".pro"& qGestion &"_4P, Procesos"& qGestion &".pro"& qGestion &"_5P, Procesos"& qGestion &".pro"& qGestion &"_6P, Procesos"& qGestion &".pro"& qGestion &"_7P, Procesos"& qGestion &".pro"& qGestion &"_8P, Procesos"& qGestion &".pro"& qGestion &"_9P, Procesos"& qGestion &".pro"& qGestion &"_10P, Procesos"& qGestion &".pro"& qGestion &"_11P, Procesos"& qGestion &".pro"& qGestion &"_12P,"
    
    ' absoluto EJEC
    ' pos : 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42
    sSQL = sSQL & " Procesos"& qGestion &".pro"& qGestion &"_1E, Procesos"& qGestion &".pro"& qGestion &"_2E, Procesos"& qGestion &".pro"& qGestion &"_3E, Procesos"& qGestion &".pro"& qGestion &"_4E, Procesos"& qGestion &".pro"& qGestion &"_5E, Procesos"& qGestion &".pro"& qGestion &"_6E, Procesos"& qGestion &".pro"& qGestion &"_7E, Procesos"& qGestion &".pro"& qGestion &"_8E, Procesos"& qGestion &".pro"& qGestion &"_9E, Procesos"& qGestion &".pro"& qGestion &"_10E, Procesos"& qGestion &".pro"& qGestion &"_11E, Procesos"& qGestion &".pro"& qGestion &"_12E,"
    
    ' calidad PROG
    ' pos : 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54
    sSQL = sSQL & " Procesos"& qGestion &".pro"& qGestion &"_1_cal1_p, Procesos"& qGestion &".pro"& qGestion &"_2_cal1_p, Procesos"& qGestion &".pro"& qGestion &"_3_cal1_p, Procesos"& qGestion &".pro"& qGestion &"_4_cal1_p, Procesos"& qGestion &".pro"& qGestion &"_5_cal1_p, Procesos"& qGestion &".pro"& qGestion &"_6_cal1_p, Procesos"& qGestion &".pro"& qGestion &"_7_cal1_p, Procesos"& qGestion &".pro"& qGestion &"_8_cal1_p, Procesos"& qGestion &".pro"& qGestion &"_9_cal1_p, Procesos"& qGestion &".pro"& qGestion &"_10_cal1_p, Procesos"& qGestion &".pro"& qGestion &"_11_cal1_p, Procesos"& qGestion &".pro"& qGestion &"_12_cal1_p,"
    
    ' pos : 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66
    sSQL = sSQL & " Procesos"& qGestion &".pro"& qGestion &"_1_cal2_p, Procesos"& qGestion &".pro"& qGestion &"_2_cal2_p, Procesos"& qGestion &".pro"& qGestion &"_3_cal2_p, Procesos"& qGestion &".pro"& qGestion &"_4_cal2_p, Procesos"& qGestion &".pro"& qGestion &"_5_cal2_p, Procesos"& qGestion &".pro"& qGestion &"_6_cal2_p, Procesos"& qGestion &".pro"& qGestion &"_7_cal2_p, Procesos"& qGestion &".pro"& qGestion &"_8_cal2_p, Procesos"& qGestion &".pro"& qGestion &"_9_cal2_p, Procesos"& qGestion &".pro"& qGestion &"_10_cal2_p, Procesos"& qGestion &".pro"& qGestion &"_11_cal2_p, Procesos"& qGestion &".pro"& qGestion &"_12_cal2_p,"
    
    ' pos : 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78
    sSQL = sSQL & " Procesos"& qGestion &".pro"& qGestion &"_1_cal3_p, Procesos"& qGestion &".pro"& qGestion &"_2_cal3_p, Procesos"& qGestion &".pro"& qGestion &"_3_cal3_p, Procesos"& qGestion &".pro"& qGestion &"_4_cal3_p, Procesos"& qGestion &".pro"& qGestion &"_5_cal3_p, Procesos"& qGestion &".pro"& qGestion &"_6_cal3_p, Procesos"& qGestion &".pro"& qGestion &"_7_cal3_p, Procesos"& qGestion &".pro"& qGestion &"_8_cal3_p, Procesos"& qGestion &".pro"& qGestion &"_9_cal3_p, Procesos"& qGestion &".pro"& qGestion &"_10_cal3_p, Procesos"& qGestion &".pro"& qGestion &"_11_cal3_p, Procesos"& qGestion &".pro"& qGestion &"_12_cal3_p,"
    
    ' pos : 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90
    sSQL = sSQL & " Procesos"& qGestion &".pro"& qGestion &"_1_cal4_p, Procesos"& qGestion &".pro"& qGestion &"_2_cal4_p, Procesos"& qGestion &".pro"& qGestion &"_3_cal4_p, Procesos"& qGestion &".pro"& qGestion &"_4_cal4_p, Procesos"& qGestion &".pro"& qGestion &"_5_cal4_p, Procesos"& qGestion &".pro"& qGestion &"_6_cal4_p, Procesos"& qGestion &".pro"& qGestion &"_7_cal4_p, Procesos"& qGestion &".pro"& qGestion &"_8_cal4_p, Procesos"& qGestion &".pro"& qGestion &"_9_cal4_p, Procesos"& qGestion &".pro"& qGestion &"_10_cal4_p, Procesos"& qGestion &".pro"& qGestion &"_11_cal4_p, Procesos"& qGestion &".pro"& qGestion &"_12_cal4_p,"
    
    ' pos : 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102
    sSQL = sSQL & " Procesos"& qGestion &".pro"& qGestion &"_1_cal5_p, Procesos"& qGestion &".pro"& qGestion &"_2_cal5_p, Procesos"& qGestion &".pro"& qGestion &"_3_cal5_p, Procesos"& qGestion &".pro"& qGestion &"_4_cal5_p, Procesos"& qGestion &".pro"& qGestion &"_5_cal5_p, Procesos"& qGestion &".pro"& qGestion &"_6_cal5_p, Procesos"& qGestion &".pro"& qGestion &"_7_cal5_p, Procesos"& qGestion &".pro"& qGestion &"_8_cal5_p, Procesos"& qGestion &".pro"& qGestion &"_9_cal5_p, Procesos"& qGestion &".pro"& qGestion &"_10_cal5_p, Procesos"& qGestion &".pro"& qGestion &"_11_cal5_p, Procesos"& qGestion &".pro"& qGestion &"_12_cal5_p,"
    
    ' calidad EJEC
    ' pos : 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114
    sSQL = sSQL & " Procesos"& qGestion &".pro"& qGestion &"_1_cal1_e, Procesos"& qGestion &".pro"& qGestion &"_2_cal1_e, Procesos"& qGestion &".pro"& qGestion &"_3_cal1_e, Procesos"& qGestion &".pro"& qGestion &"_4_cal1_e, Procesos"& qGestion &".pro"& qGestion &"_5_cal1_e, Procesos"& qGestion &".pro"& qGestion &"_6_cal1_e, Procesos"& qGestion &".pro"& qGestion &"_7_cal1_e, Procesos"& qGestion &".pro"& qGestion &"_8_cal1_e, Procesos"& qGestion &".pro"& qGestion &"_9_cal1_e, Procesos"& qGestion &".pro"& qGestion &"_10_cal1_e, Procesos"& qGestion &".pro"& qGestion &"_11_cal1_e, Procesos"& qGestion &".pro"& qGestion &"_12_cal1_e,"
    
    ' pos : 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126
    sSQL = sSQL & " Procesos"& qGestion &".pro"& qGestion &"_1_cal2_e, Procesos"& qGestion &".pro"& qGestion &"_2_cal2_e, Procesos"& qGestion &".pro"& qGestion &"_3_cal2_e, Procesos"& qGestion &".pro"& qGestion &"_4_cal2_e, Procesos"& qGestion &".pro"& qGestion &"_5_cal2_e, Procesos"& qGestion &".pro"& qGestion &"_6_cal2_e, Procesos"& qGestion &".pro"& qGestion &"_7_cal2_e, Procesos"& qGestion &".pro"& qGestion &"_8_cal2_e, Procesos"& qGestion &".pro"& qGestion &"_9_cal2_e, Procesos"& qGestion &".pro"& qGestion &"_10_cal2_e, Procesos"& qGestion &".pro"& qGestion &"_11_cal2_e, Procesos"& qGestion &".pro"& qGestion &"_12_cal2_e,"
    
    ' pos : 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138
    sSQL = sSQL & " Procesos"& qGestion &".pro"& qGestion &"_1_cal3_e, Procesos"& qGestion &".pro"& qGestion &"_2_cal3_e, Procesos"& qGestion &".pro"& qGestion &"_3_cal3_e, Procesos"& qGestion &".pro"& qGestion &"_4_cal3_e, Procesos"& qGestion &".pro"& qGestion &"_5_cal3_e, Procesos"& qGestion &".pro"& qGestion &"_6_cal3_e, Procesos"& qGestion &".pro"& qGestion &"_7_cal3_e, Procesos"& qGestion &".pro"& qGestion &"_8_cal3_e, Procesos"& qGestion &".pro"& qGestion &"_9_cal3_e, Procesos"& qGestion &".pro"& qGestion &"_10_cal3_e, Procesos"& qGestion &".pro"& qGestion &"_11_cal3_e, Procesos"& qGestion &".pro"& qGestion &"_12_cal3_e,"
    
    ' pos : 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150
    sSQL = sSQL & " Procesos"& qGestion &".pro"& qGestion &"_1_cal4_e, Procesos"& qGestion &".pro"& qGestion &"_2_cal4_e, Procesos"& qGestion &".pro"& qGestion &"_3_cal4_e, Procesos"& qGestion &".pro"& qGestion &"_4_cal4_e, Procesos"& qGestion &".pro"& qGestion &"_5_cal4_e, Procesos"& qGestion &".pro"& qGestion &"_6_cal4_e, Procesos"& qGestion &".pro"& qGestion &"_7_cal4_e, Procesos"& qGestion &".pro"& qGestion &"_8_cal4_e, Procesos"& qGestion &".pro"& qGestion &"_9_cal4_e, Procesos"& qGestion &".pro"& qGestion &"_10_cal4_e, Procesos"& qGestion &".pro"& qGestion &"_11_cal4_e, Procesos"& qGestion &".pro"& qGestion &"_12_cal4_e,"
    
    ' pos : 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162
    sSQL = sSQL & " Procesos"& qGestion &".pro"& qGestion &"_1_cal5_e, Procesos"& qGestion &".pro"& qGestion &"_2_cal5_e, Procesos"& qGestion &".pro"& qGestion &"_3_cal5_e, Procesos"& qGestion &".pro"& qGestion &"_4_cal5_e, Procesos"& qGestion &".pro"& qGestion &"_5_cal5_e, Procesos"& qGestion &".pro"& qGestion &"_6_cal5_e, Procesos"& qGestion &".pro"& qGestion &"_7_cal5_e, Procesos"& qGestion &".pro"& qGestion &"_8_cal5_e, Procesos"& qGestion &".pro"& qGestion &"_9_cal5_e, Procesos"& qGestion &".pro"& qGestion &"_10_cal5_e, Procesos"& qGestion &".pro"& qGestion &"_11_cal5_e, Procesos"& qGestion &".pro"& qGestion &"_12_cal5_e,"
    
    ' relativo PROG
    ' pos : 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174
    sSQL = sSQL & " Procesos"& qGestion &".pro"& qGestion &"_1_rel1_p, Procesos"& qGestion &".pro"& qGestion &"_2_rel1_p, Procesos"& qGestion &".pro"& qGestion &"_3_rel1_p, Procesos"& qGestion &".pro"& qGestion &"_4_rel1_p, Procesos"& qGestion &".pro"& qGestion &"_5_rel1_p, Procesos"& qGestion &".pro"& qGestion &"_6_rel1_p, Procesos"& qGestion &".pro"& qGestion &"_7_rel1_p, Procesos"& qGestion &".pro"& qGestion &"_8_rel1_p, Procesos"& qGestion &".pro"& qGestion &"_9_rel1_p, Procesos"& qGestion &".pro"& qGestion &"_10_rel1_p, Procesos"& qGestion &".pro"& qGestion &"_11_rel1_p, Procesos"& qGestion &".pro"& qGestion &"_12_rel1_p,"
    
    ' pos : 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186
    sSQL = sSQL & " Procesos"& qGestion &".pro"& qGestion &"_1_rel2_p, Procesos"& qGestion &".pro"& qGestion &"_2_rel2_p, Procesos"& qGestion &".pro"& qGestion &"_3_rel2_p, Procesos"& qGestion &".pro"& qGestion &"_4_rel2_p, Procesos"& qGestion &".pro"& qGestion &"_5_rel2_p, Procesos"& qGestion &".pro"& qGestion &"_6_rel2_p, Procesos"& qGestion &".pro"& qGestion &"_7_rel2_p, Procesos"& qGestion &".pro"& qGestion &"_8_rel2_p, Procesos"& qGestion &".pro"& qGestion &"_9_rel2_p, Procesos"& qGestion &".pro"& qGestion &"_10_rel2_p, Procesos"& qGestion &".pro"& qGestion &"_11_rel2_p, Procesos"& qGestion &".pro"& qGestion &"_12_rel2_p,"
    
    ' pos : 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198
    sSQL = sSQL & " Procesos"& qGestion &".pro"& qGestion &"_1_rel3_p, Procesos"& qGestion &".pro"& qGestion &"_2_rel3_p, Procesos"& qGestion &".pro"& qGestion &"_3_rel3_p, Procesos"& qGestion &".pro"& qGestion &"_4_rel3_p, Procesos"& qGestion &".pro"& qGestion &"_5_rel3_p, Procesos"& qGestion &".pro"& qGestion &"_6_rel3_p, Procesos"& qGestion &".pro"& qGestion &"_7_rel3_p, Procesos"& qGestion &".pro"& qGestion &"_8_rel3_p, Procesos"& qGestion &".pro"& qGestion &"_9_rel3_p, Procesos"& qGestion &".pro"& qGestion &"_10_rel3_p, Procesos"& qGestion &".pro"& qGestion &"_11_rel3_p, Procesos"& qGestion &".pro"& qGestion &"_12_rel3_p,"
    
    ' relativo EJEC
    ' pos : 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210
    sSQL = sSQL & " Procesos"& qGestion &".pro"& qGestion &"_1_rel1_e, Procesos"& qGestion &".pro"& qGestion &"_2_rel1_e, Procesos"& qGestion &".pro"& qGestion &"_3_rel1_e, Procesos"& qGestion &".pro"& qGestion &"_4_rel1_e, Procesos"& qGestion &".pro"& qGestion &"_5_rel1_e, Procesos"& qGestion &".pro"& qGestion &"_6_rel1_e, Procesos"& qGestion &".pro"& qGestion &"_7_rel1_e, Procesos"& qGestion &".pro"& qGestion &"_8_rel1_e, Procesos"& qGestion &".pro"& qGestion &"_9_rel1_e, Procesos"& qGestion &".pro"& qGestion &"_10_rel1_e, Procesos"& qGestion &".pro"& qGestion &"_11_rel1_e, Procesos"& qGestion &".pro"& qGestion &"_12_rel1_e,"
    
    ' pos : 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222
    sSQL = sSQL & " Procesos"& qGestion &".pro"& qGestion &"_1_rel2_e, Procesos"& qGestion &".pro"& qGestion &"_2_rel2_e, Procesos"& qGestion &".pro"& qGestion &"_3_rel2_e, Procesos"& qGestion &".pro"& qGestion &"_4_rel2_e, Procesos"& qGestion &".pro"& qGestion &"_5_rel2_e, Procesos"& qGestion &".pro"& qGestion &"_6_rel2_e, Procesos"& qGestion &".pro"& qGestion &"_7_rel2_e, Procesos"& qGestion &".pro"& qGestion &"_8_rel2_e, Procesos"& qGestion &".pro"& qGestion &"_9_rel2_e, Procesos"& qGestion &".pro"& qGestion &"_10_rel2_e, Procesos"& qGestion &".pro"& qGestion &"_11_rel2_e, Procesos"& qGestion &".pro"& qGestion &"_12_rel2_e,"
    
    ' pos : 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234 ... 235
    sSQL = sSQL & " Procesos"& qGestion &".pro"& qGestion &"_1_rel3_e, Procesos"& qGestion &".pro"& qGestion &"_2_rel3_e, Procesos"& qGestion &".pro"& qGestion &"_3_rel3_e, Procesos"& qGestion &".pro"& qGestion &"_4_rel3_e, Procesos"& qGestion &".pro"& qGestion &"_5_rel3_e, Procesos"& qGestion &".pro"& qGestion &"_6_rel3_e, Procesos"& qGestion &".pro"& qGestion &"_7_rel3_e, Procesos"& qGestion &".pro"& qGestion &"_8_rel3_e, Procesos"& qGestion &".pro"& qGestion &"_9_rel3_e, Procesos"& qGestion &".pro"& qGestion &"_10_rel3_e, Procesos"& qGestion &".pro"& qGestion &"_11_rel3_e, Procesos"& qGestion &".pro"& qGestion &"_12_rel3_e"
    
    sSQL = sSQL & " FROM Procesos"& qGestion &""
    sSQL = sSQL & " INNER JOIN PEspecifico"& qGestion &" ON Procesos"& qGestion &".pesp"& qGestion &"_id = PEspecifico"& qGestion &".pesp"& qGestion &"_id"
    sSQL = sSQL & " INNER JOIN POperacion"& qGestion &" ON PEspecifico"& qGestion &".pope"& qGestion &"_id = POperacion"& qGestion &".pope"& qGestion &"_id"
    sSQL = sSQL & " INNER JOIN Productos"& qGestion &" ON POperacion"& qGestion &".p"& qGestion &"_id = Productos"& qGestion &".p"& qGestion &"_id"
    sSQL = sSQL & " INNER JOIN ObjetivosGestion"& qGestion &" ON Productos"& qGestion &".o"& qGestion &"_id = ObjetivosGestion"& qGestion &".o"& qGestion &"_id"
    sSQL = sSQL & " INNER JOIN ObjetivosEstrategicos ON ObjetivosGestion"& qGestion &".obje_id = ObjetivosEstrategicos.obje_id"
    sSQL = sSQL & " INNER JOIN POAObjetivosEstrategicos ON ObjetivosEstrategicos.obje_id = POAObjetivosEstrategicos.obje_id"
    sSQL = sSQL & " INNER JOIN POA ON POAObjetivosEstrategicos.poa_id = POA.poa_id"
    sSQL = sSQL & " WHERE (POA.aper_id = "& MatrizPrograma(0,x) &") AND (POperacion"& qGestion &".aper_id = "& MatrizApertura(0,k) &")" 				
    
    MATGain = MatrixBD(sSQL, 1)
    If VarType(MATGain) = 8  then
      qGain = -1
    Else
      qGain = UBound(MATGain,2)	
    End If
    SumPA1p = 0
    SumPA2p = 0
    SumPA3p = 0
    SumPA4p = 0
    SumPA5p = 0
    SumPA6p = 0
    SumPA7p = 0
    SumPA8p = 0
    SumPA9p = 0
    SumPA10p = 0
    SumPA11p = 0
    SumPA12p = 0
    
    SumEA1p = 0
    SumEA2p = 0
    SumEA3p = 0
    SumEA4p = 0
    SumEA5p = 0
    SumEA6p = 0
    SumEA7p = 0
    SumEA8p = 0
    SumEA9p = 0
    SumEA10p = 0
    SumEA11p = 0
    SumEA12p = 0
    
    For cnt = 0 To qGain
            
      If CInt(MATGain(5,cnt)) = 1 Then 
              P1 = CDbl(MATGain(19,cnt))
        P2 = CDbl(MATGain(20,cnt))
        P3 = CDbl(MATGain(21,cnt))
        P4 = CDbl(MATGain(22,cnt))
        P5 = CDbl(MATGain(23,cnt))
        P6 = CDbl(MATGain(24,cnt))
        P7 = CDbl(MATGain(25,cnt))
        P8 = CDbl(MATGain(26,cnt))
        P9 = CDbl(MATGain(27,cnt))
        P10 = CDbl(MATGain(28,cnt))
        P11 = CDbl(MATGain(29,cnt))
        P12 = CDbl(MATGain(30,cnt))
        
        E1 = CDbl(MATGain(31,cnt))
        E2 = CDbl(MATGain(32,cnt))
        E3 = CDbl(MATGain(33,cnt))
        E4 = CDbl(MATGain(34,cnt))
        E5 = CDbl(MATGain(35,cnt))
        E6 = CDbl(MATGain(36,cnt))
        E7 = CDbl(MATGain(37,cnt))
        E8 = CDbl(MATGain(38,cnt))
        E9 = CDbl(MATGain(39,cnt))
        E10 = CDbl(MATGain(40,cnt))
        E11 = CDbl(MATGain(41,cnt))
        E12 = CDbl(MATGain(42,cnt))
                          
        Meta = CDbl(MATGain(9,cnt))
        Ponderacion = CDbl(MATGain(15,cnt))
        
        If P1 = 0 Then : EF1 = 0 : Else : EF1 = E1/P1 : End If
        If P2 = 0 Then : EF2 = 0 : Else : EF2 = E2/P2 : End If
        If P3 = 0 Then : EF3 = 0 : Else : EF3 = E3/P3 : End If
        If P4 = 0 Then : EF4 = 0 : Else : EF4 = E4/P4 : End If
        If P5 = 0 Then : EF5 = 0 : Else : EF5 = E5/P5 : End If
        If P6 = 0 Then : EF6 = 0 : Else : EF6 = E6/P6 : End If
        If P7 = 0 Then : EF7 = 0 : Else : EF7 = E7/P7 : End If
        If P8 = 0 Then : EF8 = 0 : Else : EF8 = E8/P8 : End If
        If P9 = 0 Then : EF9 = 0 : Else : EF9 = E9/P9 : End If
        If P10 = 0 Then : EF10 = 0 : Else : EF10 = E10/P10 : End If
        If P11 = 0 Then : EF11 = 0 : Else : EF11 = E11/P11 : End If
        If P12 = 0 Then : EF12 = 0 : Else : EF12 = E12/P12 : End If
                          
        PA1 = P1
        PA2 = P1+P2
        PA3 = P1+P2+P3
        PA4 = P1+P2+P3+P4
        PA5 = P1+P2+P3+P4+P5
        PA6 = P1+P2+P3+P4+P5+P6
        PA7 = P1+P2+P3+P4+P5+P6+P7
        PA8 = P1+P2+P3+P4+P5+P6+P7+P8
        PA9 = P1+P2+P3+P4+P5+P6+P7+P8+P9
        PA10 = P1+P2+P3+P4+P5+P6+P7+P8+P9+P10
        PA11 = P1+P2+P3+P4+P5+P6+P7+P8+P9+P10+P11
        PA12 = P1+P2+P3+P4+P5+P6+P7+P8+P9+P10+P11+P12
                          
        EA1 = E1
        EA2 = E1+E2
        EA3 = E1+E2+E3
        EA4 = E1+E2+E3+E4
        EA5 = E1+E2+E3+E4+E5
        EA6 = E1+E2+E3+E4+E5+E6
        EA7 = E1+E2+E3+E4+E5+E6+E7
        EA8 = E1+E2+E3+E4+E5+E6+E7+E8
        EA9 = E1+E2+E3+E4+E5+E6+E7+E8+E9
        EA10 = E1+E2+E3+E4+E5+E6+E7+E8+E9+E10
        EA11 = E1+E2+E3+E4+E5+E6+E7+E8+E9+E10+E11
        EA12 = E1+E2+E3+E4+E5+E6+E7+E8+E9+E10+E11+E12
                         
        If Meta = 0 Then : PA1p = 0 : Else : PA1p = PA1/Meta : End If
        If Meta = 0 Then : PA2p = 0 : Else : PA2p = PA2/Meta : End If
        If Meta = 0 Then : PA3p = 0 : Else : PA3p = PA3/Meta : End If
        If Meta = 0 Then : PA4p = 0 : Else : PA4p = PA4/Meta : End If
        If Meta = 0 Then : PA5p = 0 : Else : PA5p = PA5/Meta : End If
        If Meta = 0 Then : PA6p = 0 : Else : PA6p = PA6/Meta : End If
        If Meta = 0 Then : PA7p = 0 : Else : PA7p = PA7/Meta : End If
        If Meta = 0 Then : PA8p = 0 : Else : PA8p = PA8/Meta : End If
        If Meta = 0 Then : PA9p = 0 : Else : PA9p = PA9/Meta : End If
        If Meta = 0 Then : PA10p = 0 : Else : PA10p = PA10/Meta : End If
        If Meta = 0 Then : PA11p = 0 : Else : PA11p = PA11/Meta : End If
        If Meta = 0 Then : PA12p = 0 : Else : PA12p = PA12/Meta : End If
                          
        SumPA1p = SumPA1p + (PA1p*Ponderacion)
        SumPA2p = SumPA2p + (PA2p*Ponderacion)
        SumPA3p = SumPA3p + (PA3p*Ponderacion)
        SumPA4p = SumPA4p + (PA4p*Ponderacion)
        SumPA5p = SumPA5p + (PA5p*Ponderacion)
        SumPA6p = SumPA6p + (PA6p*Ponderacion)
        SumPA7p = SumPA7p + (PA7p*Ponderacion)
        SumPA8p = SumPA8p + (PA8p*Ponderacion)
        SumPA9p = SumPA9p + (PA9p*Ponderacion)
        SumPA10p = SumPA10p + (PA10p*Ponderacion)
        SumPA11p = SumPA11p + (PA11p*Ponderacion)
        SumPA12p = SumPA12p + (PA12p*Ponderacion)
                          
        If Meta = 0 Then : EA1p = 0 : Else : EA1p = EA1/Meta : End If
        If Meta = 0 Then : EA2p = 0 : Else : EA2p = EA2/Meta : End If
        If Meta = 0 Then : EA3p = 0 : Else : EA3p = EA3/Meta : End If
        If Meta = 0 Then : EA4p = 0 : Else : EA4p = EA4/Meta : End If
        If Meta = 0 Then : EA5p = 0 : Else : EA5p = EA5/Meta : End If
        If Meta = 0 Then : EA6p = 0 : Else : EA6p = EA6/Meta : End If
        If Meta = 0 Then : EA7p = 0 : Else : EA7p = EA7/Meta : End If
        If Meta = 0 Then : EA8p = 0 : Else : EA8p = EA8/Meta : End If
        If Meta = 0 Then : EA9p = 0 : Else : EA9p = EA9/Meta : End If
        If Meta = 0 Then : EA10p = 0 : Else : EA10p = EA10/Meta : End If
        If Meta = 0 Then : EA11p = 0 : Else : EA11p = EA11/Meta : End If
        If Meta = 0 Then : EA12p = 0 : Else : EA12p = EA12/Meta : End If
        
        SumEA1p = SumEA1p + (EA1p*Ponderacion)
        SumEA2p = SumEA2p + (EA2p*Ponderacion)
        SumEA3p = SumEA3p + (EA3p*Ponderacion)
        SumEA4p = SumEA4p + (EA4p*Ponderacion)
        SumEA5p = SumEA5p + (EA5p*Ponderacion)
        SumEA6p = SumEA6p + (EA6p*Ponderacion)
        
        SumEA7p = SumEA7p + (EA7p*Ponderacion)
        SumEA8p = SumEA8p + (EA8p*Ponderacion)
        SumEA9p = SumEA9p + (EA9p*Ponderacion)
        SumEA10p = SumEA10p + (EA10p*Ponderacion)
        SumEA11p = SumEA11p + (EA11p*Ponderacion)
        SumEA12p = SumEA12p + (EA12p*Ponderacion)
                          
        If PA1p = 0 Then : EEA1 = 0 : Else : EEA1 = EA1p/PA1p : End If
        If PA2p = 0 Then : EEA2 = 0 : Else : EEA2 = EA2p/PA2p : End If
        If PA3p = 0 Then : EEA3 = 0 : Else : EEA3 = EA3p/PA3p : End If
        If PA4p = 0 Then : EEA4 = 0 : Else : EEA4 = EA4p/PA4p : End If
        If PA5p = 0 Then : EEA5 = 0 : Else : EEA5 = EA5p/PA5p : End If
        If PA6p = 0 Then : EEA6 = 0 : Else : EEA6 = EA6p/PA6p : End If
        If PA7p = 0 Then : EEA7 = 0 : Else : EEA7 = EA7p/PA7p : End If
        If PA8p = 0 Then : EEA8 = 0 : Else : EEA8 = EA8p/PA8p : End If
        If PA9p = 0 Then : EEA9 = 0 : Else : EEA9 = EA9p/PA9p : End If
        If PA10p = 0 Then : EEA10 = 0 : Else : EEA10 = EA10p/PA10p : End If
        If PA11p = 0 Then : EEA11 = 0 : Else : EEA11 = EA11p/PA11p : End If
        If PA12p = 0 Then : EEA12 = 0 : Else : EEA12 = EA12p/PA12p : End If
      End If 
      If CInt(MATGain(5,cnt)) = 2 Then
      
        ' 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174
        ' pos : 199, 211, 223 /// 199 = nsam, 211 = nsap, 223 = nsafp
        If CDbl(MATGain(199,cnt)) <> 0 Then
          relativo1E = (CDbl(MATGain(211,cnt))/CDbl(MATGain(199,cnt))) * CDbl(MATGain(163,cnt))
        Else
          relativo1E = 0
        End If
        ' pos : 200, 212, 224
        If CDbl(MATGain(200,cnt)) <> 0 Then
          relativo2E = (CDbl(MATGain(212,cnt))/CDbl(MATGain(200,cnt))) * CDbl(MATGain(164,cnt))
        Else

          relativo2E = 0
        End If
        ' pos : 201, 213, 225
        If CDbl(MATGain(201,cnt)) <> 0 Then
          relativo3E = (CDbl(MATGain(213,cnt))/CDbl(MATGain(201,cnt))) * CDbl(MATGain(165,cnt))
        Else
          relativo3E = 0
        End If
        ' pos : 202, 214, 226
        If CDbl(MATGain(202,cnt)) <> 0 Then
          relativo4E = (CDbl(MATGain(214,cnt))/CDbl(MATGain(202,cnt))) * CDbl(MATGain(166,cnt))
        Else
          relativo4E = 0
        End If
        ' pos : 203, 215, 227
        If CDbl(MATGain(203,cnt)) <> 0 Then
          relativo5E = (CDbl(MATGain(215,cnt))/CDbl(MATGain(203,cnt))) * CDbl(MATGain(167,cnt))
        Else
          relativo5E = 0
        End If
        ' pos : 204, 216, 228
        If CDbl(MATGain(204,cnt)) <> 0 Then
          relativo6E = (CDbl(MATGain(216,cnt))/CDbl(MATGain(204,cnt))) * CDbl(MATGain(168,cnt))
        Else
          relativo6E = 0
        End If
        ' pos : 205 217, 229
        If CDbl(MATGain(205,cnt)) <> 0 Then
          relativo7E = (CDbl(MATGain(217,cnt))/CDbl(MATGain(205,cnt))) * CDbl(MATGain(169,cnt))
        Else
          relativo7E = 0
        End If
        ' pos : 206, 218, 230
        If CDbl(MATGain(206,cnt)) <> 0 Then
          relativo8E = (CDbl(MATGain(218,cnt))/CDbl(MATGain(206,cnt))) * CDbl(MATGain(170,cnt))
        Else
          relativo8E = 0
        End If
        ' pos : 207, 219, 231
        If CDbl(MATGain(207,cnt)) <> 0 Then
          relativo9E = (CDbl(MATGain(219,cnt))/CDbl(MATGain(207,cnt))) * CDbl(MATGain(171,cnt))
        Else
          relativo9E = 0
        End If
        ' pos : 208, 220, 232
        If CDbl(MATGain(208,cnt)) <> 0 Then
          relativo10E = (CDbl(MATGain(220,cnt))/CDbl(MATGain(208,cnt))) * CDbl(MATGain(172,cnt))
        Else
          relativo10E = 0
        End If
        ' pos : 209, 221, 233
        If CDbl(MATGain(209,cnt)) <> 0 Then
          relativo11E = (CDbl(MATGain(221,cnt))/CDbl(MATGain(209,cnt))) * CDbl(MATGain(173,cnt))
        Else
          relativo11E = 0
        End If
        ' pos : 210, 222, 234
        If CDbl(MATGain(210,cnt)) <> 0 Then
          relativo12E = (CDbl(MATGain(222,cnt))/CDbl(MATGain(210,cnt))) * CDbl(MATGain(174,cnt))
        Else
          relativo12E = 0
        End If
                         
        P1 = CDbl(MATGain(163,cnt))
        P2 = CDbl(MATGain(164,cnt))
        P3 = CDbl(MATGain(165,cnt))
        P4 = CDbl(MATGain(166,cnt))
        P5 = CDbl(MATGain(167,cnt))
        P6 = CDbl(MATGain(168,cnt))
        P7 = CDbl(MATGain(169,cnt))
        P8 = CDbl(MATGain(170,cnt))
        P9 = CDbl(MATGain(171,cnt))
        P10 = CDbl(MATGain(172,cnt))
        P11 = CDbl(MATGain(173,cnt))
        P12 = CDbl(MATGain(174,cnt))
        
        E1 = CDbl(relativo1E)
        E2 = CDbl(relativo2E)
        E3 = CDbl(relativo3E)
        E4 = CDbl(relativo4E)
        E5 = CDbl(relativo5E)
        E6 = CDbl(relativo6E)
        E7 = CDbl(relativo7E)
        E8 = CDbl(relativo8E)
        E9 = CDbl(relativo9E)
        E10 = CDbl(relativo10E)
        E11 = CDbl(relativo11E)
        E12 = CDbl(relativo12E)
                          
        Meta = CDbl(MATGain(9,cnt))
        Ponderacion = CDbl(MATGain(15,cnt))
        
        If P1 = 0 Then : EF1 = 0 : Else : EF1 = E1/P1 : End If
        If P2 = 0 Then : EF2 = 0 : Else : EF2 = E2/P2 : End If
        If P3 = 0 Then : EF3 = 0 : Else : EF3 = E3/P3 : End If
        If P4 = 0 Then : EF4 = 0 : Else : EF4 = E4/P4 : End If
        If P5 = 0 Then : EF5 = 0 : Else : EF5 = E5/P5 : End If
        If P6 = 0 Then : EF6 = 0 : Else : EF6 = E6/P6 : End If
        If P7 = 0 Then : EF7 = 0 : Else : EF7 = E7/P7 : End If
        If P8 = 0 Then : EF8 = 0 : Else : EF8 = E8/P8 : End If
        If P9 = 0 Then : EF9 = 0 : Else : EF9 = E9/P9 : End If
        If P10 = 0 Then : EF10 = 0 : Else : EF10 = E10/P10 : End If
        If P11 = 0 Then : EF11 = 0 : Else : EF11 = E11/P11 : End If
        If P12 = 0 Then : EF12 = 0 : Else : EF12 = E12/P12 : End If
        
        PA1 = P1
        PA2 = P1+P2
        PA3 = P1+P2+P3
        PA4 = P1+P2+P3+P4
        PA5 = P1+P2+P3+P4+P5
        PA6 = P1+P2+P3+P4+P5+P6
        PA7 = P1+P2+P3+P4+P5+P6+P7
        PA8 = P1+P2+P3+P4+P5+P6+P7+P8
        PA9 = P1+P2+P3+P4+P5+P6+P7+P8+P9
        PA10 = P1+P2+P3+P4+P5+P6+P7+P8+P9+P10
        PA11 = P1+P2+P3+P4+P5+P6+P7+P8+P9+P10+P11
        PA12 = P1+P2+P3+P4+P5+P6+P7+P8+P9+P10+P11+P12
        
        EA1 = E1
        EA2 = E1+E2
        EA3 = E1+E2+E3
        EA4 = E1+E2+E3+E4
        EA5 = E1+E2+E3+E4+E5
        EA6 = E1+E2+E3+E4+E5+E6
        EA7 = E1+E2+E3+E4+E5+E6+E7
        EA8 = E1+E2+E3+E4+E5+E6+E7+E8
        EA9 = E1+E2+E3+E4+E5+E6+E7+E8+E9
        EA10 = E1+E2+E3+E4+E5+E6+E7+E8+E9+E10
        EA11 = E1+E2+E3+E4+E5+E6+E7+E8+E9+E10+E11
        EA12 = E1+E2+E3+E4+E5+E6+E7+E8+E9+E10+E11+E12
        
        If Meta = 0 Then : PA1p = 0 : Else : PA1p = PA1/Meta : End If
        If Meta = 0 Then : PA2p = 0 : Else : PA2p = PA2/Meta : End If
        If Meta = 0 Then : PA3p = 0 : Else : PA3p = PA3/Meta : End If
        If Meta = 0 Then : PA4p = 0 : Else : PA4p = PA4/Meta : End If
        If Meta = 0 Then : PA5p = 0 : Else : PA5p = PA5/Meta : End If
        If Meta = 0 Then : PA6p = 0 : Else : PA6p = PA6/Meta : End If
        If Meta = 0 Then : PA7p = 0 : Else : PA7p = PA7/Meta : End If
        If Meta = 0 Then : PA8p = 0 : Else : PA8p = PA8/Meta : End If
        If Meta = 0 Then : PA9p = 0 : Else : PA9p = PA9/Meta : End If
        If Meta = 0 Then : PA10p = 0 : Else : PA10p = PA10/Meta : End If
        If Meta = 0 Then : PA11p = 0 : Else : PA11p = PA11/Meta : End If
        If Meta = 0 Then : PA12p = 0 : Else : PA12p = PA12/Meta : End If
        
        SumPA1p = SumPA1p + (PA1p*Ponderacion)
        SumPA2p = SumPA2p + (PA2p*Ponderacion)
        SumPA3p = SumPA3p + (PA3p*Ponderacion)
        SumPA4p = SumPA4p + (PA4p*Ponderacion)
        SumPA5p = SumPA5p + (PA5p*Ponderacion)
        SumPA6p = SumPA6p + (PA6p*Ponderacion)
        SumPA7p = SumPA7p + (PA7p*Ponderacion)
        SumPA8p = SumPA8p + (PA8p*Ponderacion)
        SumPA9p = SumPA9p + (PA9p*Ponderacion)
        SumPA10p = SumPA10p + (PA10p*Ponderacion)
        SumPA11p = SumPA11p + (PA11p*Ponderacion)
        SumPA12p = SumPA12p + (PA12p*Ponderacion)
        
        If Meta = 0 Then : EA1p = 0 : Else : EA1p = EA1/Meta : End If
        If Meta = 0 Then : EA2p = 0 : Else : EA2p = EA2/Meta : End If
        If Meta = 0 Then : EA3p = 0 : Else : EA3p = EA3/Meta : End If
        If Meta = 0 Then : EA4p = 0 : Else : EA4p = EA4/Meta : End If
        If Meta = 0 Then : EA5p = 0 : Else : EA5p = EA5/Meta : End If
        If Meta = 0 Then : EA6p = 0 : Else : EA6p = EA6/Meta : End If
        If Meta = 0 Then : EA7p = 0 : Else : EA7p = EA7/Meta : End If
        If Meta = 0 Then : EA8p = 0 : Else : EA8p = EA8/Meta : End If
        If Meta = 0 Then : EA9p = 0 : Else : EA9p = EA9/Meta : End If
        If Meta = 0 Then : EA10p = 0 : Else : EA10p = EA10/Meta : End If
        If Meta = 0 Then : EA11p = 0 : Else : EA11p = EA11/Meta : End If
        If Meta = 0 Then : EA12p = 0 : Else : EA12p = EA12/Meta : End If
        
        SumEA1p = SumEA1p + (EA1p*Ponderacion)
        SumEA2p = SumEA2p + (EA2p*Ponderacion)
        SumEA3p = SumEA3p + (EA3p*Ponderacion)
        SumEA4p = SumEA4p + (EA4p*Ponderacion)
        SumEA5p = SumEA5p + (EA5p*Ponderacion)
        SumEA6p = SumEA6p + (EA6p*Ponderacion)
        SumEA7p = SumEA7p + (EA7p*Ponderacion)
        SumEA8p = SumEA8p + (EA8p*Ponderacion)
        SumEA9p = SumEA9p + (EA9p*Ponderacion)
        SumEA10p = SumEA10p + (EA10p*Ponderacion)
        SumEA11p = SumEA11p + (EA11p*Ponderacion)
        SumEA12p = SumEA12p + (EA12p*Ponderacion)
        
        If PA1p = 0 Then : EEA1 = 0 : Else : EEA1 = EA1p/PA1p : End If
        If PA2p = 0 Then : EEA2 = 0 : Else : EEA2 = EA2p/PA2p : End If
        If PA3p = 0 Then : EEA3 = 0 : Else : EEA3 = EA3p/PA3p : End If
        If PA4p = 0 Then : EEA4 = 0 : Else : EEA4 = EA4p/PA4p : End If
        If PA5p = 0 Then : EEA5 = 0 : Else : EEA5 = EA5p/PA5p : End If
        If PA6p = 0 Then : EEA6 = 0 : Else : EEA6 = EA6p/PA6p : End If
        If PA7p = 0 Then : EEA7 = 0 : Else : EEA7 = EA7p/PA7p : End If
        If PA8p = 0 Then : EEA8 = 0 : Else : EEA8 = EA8p/PA8p : End If
        If PA9p = 0 Then : EEA9 = 0 : Else : EEA9 = EA9p/PA9p : End If
        If PA10p = 0 Then : EEA10 = 0 : Else : EEA10 = EA10p/PA10p : End If
        If PA11p = 0 Then : EEA11 = 0 : Else : EEA11 = EA11p/PA11p : End If
        If PA12p = 0 Then : EEA12 = 0 : Else : EEA12 = EA12p/PA12p : End If
      End If 
      If CInt(MATGain(5,cnt)) = 3 Then 
        ' pos : 43, 55, 67, 79, 91
        calidad1P = 0
        If CInt(MATGain(43,cnt)) <> 0 Then calidad1P = CInt(MATGain(43,cnt))
        If CInt(MATGain(55,cnt)) <> 0 Then calidad1P = CInt(MATGain(55,cnt))
        If CInt(MATGain(67,cnt)) <> 0 Then calidad1P = CInt(MATGain(67,cnt))
        If CInt(MATGain(79,cnt)) <> 0 Then calidad1P = CInt(MATGain(79,cnt))
        If CInt(MATGain(91,cnt)) <> 0 Then calidad1P = CInt(MATGain(91,cnt))
        ' pos : 44, 56, 68, 80, 92
        calidad2P = 0
        If CInt(MATGain(44,cnt)) <> 0 Then calidad2P = CInt(MATGain(44,cnt))
        If CInt(MATGain(56,cnt)) <> 0 Then calidad2P = CInt(MATGain(56,cnt))
        If CInt(MATGain(68,cnt)) <> 0 Then calidad2P = CInt(MATGain(68,cnt))
        If CInt(MATGain(80,cnt)) <> 0 Then calidad2P = CInt(MATGain(80,cnt))
        If CInt(MATGain(92,cnt)) <> 0 Then calidad2P = CInt(MATGain(92,cnt))
        ' pos : 45, 57, 69, 81, 93
        calidad3P = 0
        If CInt(MATGain(45,cnt)) <> 0 Then calidad3P = CInt(MATGain(45,cnt))
        If CInt(MATGain(57,cnt)) <> 0 Then calidad3P = CInt(MATGain(57,cnt))
        If CInt(MATGain(69,cnt)) <> 0 Then calidad3P = CInt(MATGain(69,cnt))
        If CInt(MATGain(81,cnt)) <> 0 Then calidad3P = CInt(MATGain(81,cnt))
        If CInt(MATGain(93,cnt)) <> 0 Then calidad3P = CInt(MATGain(93,cnt))
        ' pos : 46, 58, 70, 82, 94
        calidad4P = 0
        If CInt(MATGain(46,cnt)) <> 0 Then calidad4P = CInt(MATGain(46,cnt))
        If CInt(MATGain(58,cnt)) <> 0 Then calidad4P = CInt(MATGain(58,cnt))
        If CInt(MATGain(70,cnt)) <> 0 Then calidad4P = CInt(MATGain(70,cnt))
        If CInt(MATGain(82,cnt)) <> 0 Then calidad4P = CInt(MATGain(82,cnt))
        If CInt(MATGain(94,cnt)) <> 0 Then calidad4P = CInt(MATGain(94,cnt))
        ' pos : 47, 59, 71, 83, 95
        calidad5P = 0
        If CInt(MATGain(47,cnt)) <> 0 Then calidad5P = CInt(MATGain(47,cnt))
        If CInt(MATGain(59,cnt)) <> 0 Then calidad5P = CInt(MATGain(59,cnt))
        If CInt(MATGain(71,cnt)) <> 0 Then calidad5P = CInt(MATGain(71,cnt))
        If CInt(MATGain(83,cnt)) <> 0 Then calidad5P = CInt(MATGain(83,cnt))
        If CInt(MATGain(95,cnt)) <> 0 Then calidad5P = CInt(MATGain(95,cnt))
        ' pos : 48, 60, 72, 84, 96
        calidad6P = 0
        If CInt(MATGain(48,cnt)) <> 0 Then calidad6P = CInt(MATGain(48,cnt))
        If CInt(MATGain(60,cnt)) <> 0 Then calidad6P = CInt(MATGain(60,cnt))
        If CInt(MATGain(72,cnt)) <> 0 Then calidad6P = CInt(MATGain(72,cnt))
        If CInt(MATGain(84,cnt)) <> 0 Then calidad6P = CInt(MATGain(84,cnt))
        If CInt(MATGain(96,cnt)) <> 0 Then calidad6P = CInt(MATGain(96,cnt))
        ' pos : 49, 61, 73, 85, 97
        calidad7P = 0
        If CInt(MATGain(49,cnt)) <> 0 Then calidad7P = CInt(MATGain(49,cnt))
        If CInt(MATGain(61,cnt)) <> 0 Then calidad7P = CInt(MATGain(61,cnt))
        If CInt(MATGain(73,cnt)) <> 0 Then calidad7P = CInt(MATGain(73,cnt))
        If CInt(MATGain(85,cnt)) <> 0 Then calidad7P = CInt(MATGain(85,cnt))
        If CInt(MATGain(97,cnt)) <> 0 Then calidad7P = CInt(MATGain(97,cnt))
        ' pos : 50, 62, 74, 86, 98
        calidad8P = 0
        If CInt(MATGain(50,cnt)) <> 0 Then calidad8P = CInt(MATGain(50,cnt))
        If CInt(MATGain(62,cnt)) <> 0 Then calidad8P = CInt(MATGain(62,cnt))
        If CInt(MATGain(74,cnt)) <> 0 Then calidad8P = CInt(MATGain(74,cnt))
        If CInt(MATGain(86,cnt)) <> 0 Then calidad8P = CInt(MATGain(86,cnt))
        If CInt(MATGain(98,cnt)) <> 0 Then calidad8P = CInt(MATGain(98,cnt))
        ' pos : 51, 63, 75, 87, 99
        calidad9P = 0
        If CInt(MATGain(51,cnt)) <> 0 Then calidad9P = CInt(MATGain(51,cnt))
        If CInt(MATGain(63,cnt)) <> 0 Then calidad9P = CInt(MATGain(63,cnt))
        If CInt(MATGain(75,cnt)) <> 0 Then calidad9P = CInt(MATGain(75,cnt))
        If CInt(MATGain(87,cnt)) <> 0 Then calidad9P = CInt(MATGain(87,cnt))
        If CInt(MATGain(99,cnt)) <> 0 Then calidad9P = CInt(MATGain(99,cnt))
        ' pos : 52, 64, 76, 88, 100
        calidad10P = 0
        If CInt(MATGain(52,cnt)) <> 0 Then calidad10P = CInt(MATGain(52,cnt))
        If CInt(MATGain(64,cnt)) <> 0 Then calidad10P = CInt(MATGain(64,cnt))
        If CInt(MATGain(76,cnt)) <> 0 Then calidad10P = CInt(MATGain(76,cnt))
        If CInt(MATGain(88,cnt)) <> 0 Then calidad10P = CInt(MATGain(88,cnt))
        If CInt(MATGain(100,cnt)) <> 0 Then calidad10P = CInt(MATGain(100,cnt))
        ' pos : 53, 65, 77, 89, 101
        calidad11P = 0
        If CInt(MATGain(53,cnt)) <> 0 Then calidad11P = CInt(MATGain(53,cnt))
        If CInt(MATGain(65,cnt)) <> 0 Then calidad11P = CInt(MATGain(65,cnt))
        If CInt(MATGain(77,cnt)) <> 0 Then calidad11P = CInt(MATGain(77,cnt))
        If CInt(MATGain(89,cnt)) <> 0 Then calidad11P = CInt(MATGain(89,cnt))
        If CInt(MATGain(101,cnt)) <> 0 Then calidad11P = CInt(MATGain(101,cnt))
        ' pos : 54, 66, 78, 90, 102
        calidad12P = 0
        If CInt(MATGain(54,cnt)) <> 0 Then calidad12P = CInt(MATGain(54,cnt))
        If CInt(MATGain(66,cnt)) <> 0 Then calidad12P = CInt(MATGain(66,cnt))
        If CInt(MATGain(78,cnt)) <> 0 Then calidad12P = CInt(MATGain(78,cnt))
        If CInt(MATGain(90,cnt)) <> 0 Then calidad12P = CInt(MATGain(90,cnt))
        If CInt(MATGain(102,cnt)) <> 0 Then calidad12P = CInt(MATGain(102,cnt))
  
        
        ' pos : 103, 115, 127, 139, 151
        calidad1E = 0
        If CInt(MATGain(103,cnt)) <> 0 Then calidad1E = CInt(MATGain(103,cnt))
        If CInt(MATGain(115,cnt)) <> 0 Then calidad1E = CInt(MATGain(115,cnt))
        If CInt(MATGain(127,cnt)) <> 0 Then calidad1E = CInt(MATGain(127,cnt))
        If CInt(MATGain(139,cnt)) <> 0 Then calidad1E = CInt(MATGain(139,cnt))
        If CInt(MATGain(151,cnt)) <> 0 Then calidad1E = CInt(MATGain(151,cnt))
        ' pos : 104, 116, 128, 140, 152
        calidad2E = 0
        If CInt(MATGain(104,cnt)) <> 0 Then calidad2E = CInt(MATGain(104,cnt))
        If CInt(MATGain(116,cnt)) <> 0 Then calidad2E = CInt(MATGain(116,cnt))
        If CInt(MATGain(128,cnt)) <> 0 Then calidad2E = CInt(MATGain(128,cnt))
        If CInt(MATGain(140,cnt)) <> 0 Then calidad2E = CInt(MATGain(140,cnt))
        If CInt(MATGain(152,cnt)) <> 0 Then calidad2E = CInt(MATGain(152,cnt))
        ' pos : 105, 117, 129, 141, 153
        calidad3E = 0
        If CInt(MATGain(105,cnt)) <> 0 Then calidad3E = CInt(MATGain(105,cnt))
        If CInt(MATGain(117,cnt)) <> 0 Then calidad3E = CInt(MATGain(117,cnt))
        If CInt(MATGain(129,cnt)) <> 0 Then calidad3E = CInt(MATGain(129,cnt))
        If CInt(MATGain(141,cnt)) <> 0 Then calidad3E = CInt(MATGain(141,cnt))
        If CInt(MATGain(153,cnt)) <> 0 Then calidad3E = CInt(MATGain(153,cnt))
        ' pos : 106, 118, 130, 142, 154
        calidad4E = 0
        If CInt(MATGain(106,cnt)) <> 0 Then calidad4E = CInt(MATGain(106,cnt))
        If CInt(MATGain(118,cnt)) <> 0 Then calidad4E = CInt(MATGain(118,cnt))
        If CInt(MATGain(130,cnt)) <> 0 Then calidad4E = CInt(MATGain(130,cnt))
        If CInt(MATGain(142,cnt)) <> 0 Then calidad4E = CInt(MATGain(142,cnt))
        If CInt(MATGain(154,cnt)) <> 0 Then calidad4E = CInt(MATGain(154,cnt))
        ' pos : 107, 119, 131, 143, 155
        calidad5E = 0
        If CInt(MATGain(107,cnt)) <> 0 Then calidad5E = CInt(MATGain(107,cnt))
        If CInt(MATGain(119,cnt)) <> 0 Then calidad5E = CInt(MATGain(119,cnt))
        If CInt(MATGain(131,cnt)) <> 0 Then calidad5E = CInt(MATGain(131,cnt))
        If CInt(MATGain(143,cnt)) <> 0 Then calidad5E = CInt(MATGain(143,cnt))
        If CInt(MATGain(155,cnt)) <> 0 Then calidad5E = CInt(MATGain(155,cnt))
        ' pos : 108, 120, 132, 144, 156
        calidad6E = 0
        If CInt(MATGain(108,cnt)) <> 0 Then calidad6E = CInt(MATGain(108,cnt))
        If CInt(MATGain(120,cnt)) <> 0 Then calidad6E = CInt(MATGain(120,cnt))
        If CInt(MATGain(132,cnt)) <> 0 Then calidad6E = CInt(MATGain(132,cnt))
        If CInt(MATGain(144,cnt)) <> 0 Then calidad6E = CInt(MATGain(144,cnt))
        If CInt(MATGain(156,cnt)) <> 0 Then calidad6E = CInt(MATGain(156,cnt))
        ' pos : 109, 121, 133, 145, 157
        calidad7E = 0
  
        If CInt(MATGain(109,cnt)) <> 0 Then calidad7E = CInt(MATGain(109,cnt))
        If CInt(MATGain(121,cnt)) <> 0 Then calidad7E = CInt(MATGain(121,cnt))
        If CInt(MATGain(133,cnt)) <> 0 Then calidad7E = CInt(MATGain(133,cnt))
        If CInt(MATGain(145,cnt)) <> 0 Then calidad7E = CInt(MATGain(145,cnt))
        If CInt(MATGain(157,cnt)) <> 0 Then calidad7E = CInt(MATGain(157,cnt))
        ' pos : 110, 122, 134, 146, 158
        calidad8E = 0
        If CInt(MATGain(110,cnt)) <> 0 Then calidad8E = CInt(MATGain(110,cnt))
        If CInt(MATGain(122,cnt)) <> 0 Then calidad8E = CInt(MATGain(122,cnt))
        If CInt(MATGain(134,cnt)) <> 0 Then calidad8E = CInt(MATGain(134,cnt))
        If CInt(MATGain(146,cnt)) <> 0 Then calidad8E = CInt(MATGain(146,cnt))
        If CInt(MATGain(158,cnt)) <> 0 Then calidad8E = CInt(MATGain(158,cnt))
        ' pos : 111, 123, 135, 147, 159
        calidad9E = 0
        If CInt(MATGain(111,cnt)) <> 0 Then calidad9E = CInt(MATGain(111,cnt))
        If CInt(MATGain(123,cnt)) <> 0 Then calidad9E = CInt(MATGain(123,cnt))
        If CInt(MATGain(135,cnt)) <> 0 Then calidad9E = CInt(MATGain(135,cnt))
        If CInt(MATGain(147,cnt)) <> 0 Then calidad9E = CInt(MATGain(147,cnt))
        If CInt(MATGain(159,cnt)) <> 0 Then calidad9E = CInt(MATGain(159,cnt))
        ' pos : 112, 124, 136, 148, 160
        calidad10E = 0
        If CInt(MATGain(112,cnt)) <> 0 Then calidad10E = CInt(MATGain(112,cnt))
        If CInt(MATGain(124,cnt)) <> 0 Then calidad10E = CInt(MATGain(124,cnt))
        If CInt(MATGain(136,cnt)) <> 0 Then calidad10E = CInt(MATGain(136,cnt))
        If CInt(MATGain(148,cnt)) <> 0 Then calidad10E = CInt(MATGain(148,cnt))
        If CInt(MATGain(160,cnt)) <> 0 Then calidad10E = CInt(MATGain(160,cnt))
        ' pos : 113, 125, 137, 149, 161
        calidad11E = 0
        If CInt(MATGain(113,cnt)) <> 0 Then calidad11E = CInt(MATGain(113,cnt))
        If CInt(MATGain(125,cnt)) <> 0 Then calidad11E = CInt(MATGain(125,cnt))
        If CInt(MATGain(137,cnt)) <> 0 Then calidad11E = CInt(MATGain(137,cnt))
        If CInt(MATGain(149,cnt)) <> 0 Then calidad11E = CInt(MATGain(149,cnt))
        If CInt(MATGain(161,cnt)) <> 0 Then calidad11E = CInt(MATGain(161,cnt))
        ' pos : 114, 126, 138, 150, 162
        calidad12E = 0
        If CInt(MATGain(114,cnt)) <> 0 Then calidad12E = CInt(MATGain(114,cnt))
        If CInt(MATGain(126,cnt)) <> 0 Then calidad12E = CInt(MATGain(126,cnt))
        If CInt(MATGain(138,cnt)) <> 0 Then calidad12E = CInt(MATGain(138,cnt))
        If CInt(MATGain(150,cnt)) <> 0 Then calidad12E = CInt(MATGain(150,cnt))
        If CInt(MATGain(162,cnt)) <> 0 Then calidad12E = CInt(MATGain(162,cnt))
                        
        P1 = CDbl(calidad1P)
        P2 = CDbl(calidad2P)
        P3 = CDbl(calidad3P)
        P4 = CDbl(calidad4P)
        P5 = CDbl(calidad5P)
        P6 = CDbl(calidad6P)
        P7 = CDbl(calidad7P)
        P8 = CDbl(calidad8P)
        P9 = CDbl(calidad9P)
        P10 = CDbl(calidad10P)
        P11 = CDbl(calidad11P)
        P12 = CDbl(calidad12P)
        
        E1 = CDbl(calidad1E)
        E2 = CDbl(calidad2E)
        E3 = CDbl(calidad3E)
        E4 = CDbl(calidad4E)
        E5 = CDbl(calidad5E)
        E6 = CDbl(calidad6E)
        E7 = CDbl(calidad7E)
        E8 = CDbl(calidad8E)
        E9 = CDbl(calidad9E)
        E10 = CDbl(calidad10E)
        E11 = CDbl(calidad11E)
        E12 = CDbl(calidad12E)
        
        Meta = CDbl(MATGain(9,cnt))
        Ponderacion = CDbl(MATGain(15,cnt))
        
        If P1 = 0 Then : EF1 = 0 : Else : EF1 = E1/P1 : End If
        If P2 = 0 Then : EF2 = 0 : Else : EF2 = E2/P2 : End If
        If P3 = 0 Then : EF3 = 0 : Else : EF3 = E3/P3 : End If
        If P4 = 0 Then : EF4 = 0 : Else : EF4 = E4/P4 : End If
        If P5 = 0 Then : EF5 = 0 : Else : EF5 = E5/P5 : End If
        If P6 = 0 Then : EF6 = 0 : Else : EF6 = E6/P6 : End If
        If P7 = 0 Then : EF7 = 0 : Else : EF7 = E7/P7 : End If
        If P8 = 0 Then : EF8 = 0 : Else : EF8 = E8/P8 : End If
        If P9 = 0 Then : EF9 = 0 : Else : EF9 = E9/P9 : End If
        If P10 = 0 Then : EF10 = 0 : Else : EF10 = E10/P10 : End If
        If P11 = 0 Then : EF11 = 0 : Else : EF11 = E11/P11 : End If
        If P12 = 0 Then : EF12 = 0 : Else : EF12 = E12/P12 : End If
        
        PA1 = P1
        PA2 = P1+P2
        PA3 = P1+P2+P3
        PA4 = P1+P2+P3+P4
        PA5 = P1+P2+P3+P4+P5
        PA6 = P1+P2+P3+P4+P5+P6
        PA7 = P1+P2+P3+P4+P5+P6+P7
        PA8 = P1+P2+P3+P4+P5+P6+P7+P8
        PA9 = P1+P2+P3+P4+P5+P6+P7+P8+P9
        PA10 = P1+P2+P3+P4+P5+P6+P7+P8+P9+P10
        PA11 = P1+P2+P3+P4+P5+P6+P7+P8+P9+P10+P11
        PA12 = P1+P2+P3+P4+P5+P6+P7+P8+P9+P10+P11+P12
        
        EA1 = E1
        EA2 = E1+E2
        EA3 = E1+E2+E3
        EA4 = E1+E2+E3+E4
        EA5 = E1+E2+E3+E4+E5
        EA6 = E1+E2+E3+E4+E5+E6
        EA7 = E1+E2+E3+E4+E5+E6+E7
        EA8 = E1+E2+E3+E4+E5+E6+E7+E8
        EA9 = E1+E2+E3+E4+E5+E6+E7+E8+E9
        EA10 = E1+E2+E3+E4+E5+E6+E7+E8+E9+E10
        EA11 = E1+E2+E3+E4+E5+E6+E7+E8+E9+E10+E11
        EA12 = E1+E2+E3+E4+E5+E6+E7+E8+E9+E10+E11+E12
        
        If Meta = 0 Then : PA1p = 0 : Else : PA1p = PA1/Meta : End If
        If Meta = 0 Then : PA2p = 0 : Else : PA2p = PA2/Meta : End If
        If Meta = 0 Then : PA3p = 0 : Else : PA3p = PA3/Meta : End If
        If Meta = 0 Then : PA4p = 0 : Else : PA4p = PA4/Meta : End If
        If Meta = 0 Then : PA5p = 0 : Else : PA5p = PA5/Meta : End If
        If Meta = 0 Then : PA6p = 0 : Else : PA6p = PA6/Meta : End If
        If Meta = 0 Then : PA7p = 0 : Else : PA7p = PA7/Meta : End If
        If Meta = 0 Then : PA8p = 0 : Else : PA8p = PA8/Meta : End If
        If Meta = 0 Then : PA9p = 0 : Else : PA9p = PA9/Meta : End If
        If Meta = 0 Then : PA10p = 0 : Else : PA10p = PA10/Meta : End If
        If Meta = 0 Then : PA11p = 0 : Else : PA11p = PA11/Meta : End If
        If Meta = 0 Then : PA12p = 0 : Else : PA12p = PA12/Meta : End If
        
        SumPA1p = SumPA1p + (PA1p*Ponderacion)
        SumPA2p = SumPA2p + (PA2p*Ponderacion)
        SumPA3p = SumPA3p + (PA3p*Ponderacion)
        SumPA4p = SumPA4p + (PA4p*Ponderacion)
        SumPA5p = SumPA5p + (PA5p*Ponderacion)
        SumPA6p = SumPA6p + (PA6p*Ponderacion)
        SumPA7p = SumPA7p + (PA7p*Ponderacion)
        SumPA8p = SumPA8p + (PA8p*Ponderacion)
        SumPA9p = SumPA9p + (PA9p*Ponderacion)
        SumPA10p = SumPA10p + (PA10p*Ponderacion)
        SumPA11p = SumPA11p + (PA11p*Ponderacion)
        SumPA12p = SumPA12p + (PA12p*Ponderacion)
        
        If Meta = 0 Then : EA1p = 0 : Else : EA1p = EA1/Meta : End If
        If Meta = 0 Then : EA2p = 0 : Else : EA2p = EA2/Meta : End If
        If Meta = 0 Then : EA3p = 0 : Else : EA3p = EA3/Meta : End If
        If Meta = 0 Then : EA4p = 0 : Else : EA4p = EA4/Meta : End If
        If Meta = 0 Then : EA5p = 0 : Else : EA5p = EA5/Meta : End If
        If Meta = 0 Then : EA6p = 0 : Else : EA6p = EA6/Meta : End If
        If Meta = 0 Then : EA7p = 0 : Else : EA7p = EA7/Meta : End If
        If Meta = 0 Then : EA8p = 0 : Else : EA8p = EA8/Meta : End If
        If Meta = 0 Then : EA9p = 0 : Else : EA9p = EA9/Meta : End If
        If Meta = 0 Then : EA10p = 0 : Else : EA10p = EA10/Meta : End If
        If Meta = 0 Then : EA11p = 0 : Else : EA11p = EA11/Meta : End If
        If Meta = 0 Then : EA12p = 0 : Else : EA12p = EA12/Meta : End If
        
        SumEA1p = SumEA1p + (EA1p*Ponderacion)
        SumEA2p = SumEA2p + (EA2p*Ponderacion)
        SumEA3p = SumEA3p + (EA3p*Ponderacion)
        SumEA4p = SumEA4p + (EA4p*Ponderacion)
        SumEA5p = SumEA5p + (EA5p*Ponderacion)
        SumEA6p = SumEA6p + (EA6p*Ponderacion)
        SumEA7p = SumEA7p + (EA7p*Ponderacion)
        SumEA8p = SumEA8p + (EA8p*Ponderacion)
        SumEA9p = SumEA9p + (EA9p*Ponderacion)
        SumEA10p = SumEA10p + (EA10p*Ponderacion)
        SumEA11p = SumEA11p + (EA11p*Ponderacion)
        SumEA12p = SumEA12p + (EA12p*Ponderacion)
        
        If PA1p = 0 Then : EEA1 = 0 : Else : EEA1 = EA1p/PA1p : End If
        If PA2p = 0 Then : EEA2 = 0 : Else : EEA2 = EA2p/PA2p : End If
        If PA3p = 0 Then : EEA3 = 0 : Else : EEA3 = EA3p/PA3p : End If
        If PA4p = 0 Then : EEA4 = 0 : Else : EEA4 = EA4p/PA4p : End If
        If PA5p = 0 Then : EEA5 = 0 : Else : EEA5 = EA5p/PA5p : End If
        If PA6p = 0 Then : EEA6 = 0 : Else : EEA6 = EA6p/PA6p : End If
        If PA7p = 0 Then : EEA7 = 0 : Else : EEA7 = EA7p/PA7p : End If
        If PA8p = 0 Then : EEA8 = 0 : Else : EEA8 = EA8p/PA8p : End If
        If PA9p = 0 Then : EEA9 = 0 : Else : EEA9 = EA9p/PA9p : End If
        If PA10p = 0 Then : EEA10 = 0 : Else : EEA10 = EA10p/PA10p : End If
        If PA11p = 0 Then : EEA11 = 0 : Else : EEA11 = EA11p/PA11p : End If
        If PA12p = 0 Then : EEA12 = 0 : Else : EEA12 = EA12p/PA12p : End If
      End If 
    Next ' bucle para la variable "cnt" 
            
    If qGain > -1 Then 
      'GranPonderacion = 100 para gnerar el 100%
      GranSumPA1p = GranSumPA1p + (SumPA1p*100)
      GranSumPA2p = GranSumPA2p + (SumPA2p*100)
      GranSumPA3p = GranSumPA3p + (SumPA3p*100)
      GranSumPA4p = GranSumPA4p + (SumPA4p*100)
      GranSumPA5p = GranSumPA5p + (SumPA5p*100)
      GranSumPA6p = GranSumPA6p + (SumPA6p*100)
      GranSumPA7p = GranSumPA7p + (SumPA7p*100)
      GranSumPA8p = GranSumPA8p + (SumPA8p*100)
      GranSumPA9p = GranSumPA9p + (SumPA9p*100)
      GranSumPA10p = GranSumPA10p + (SumPA10p*100)
      GranSumPA11p = GranSumPA11p + (SumPA11p*100)
      GranSumPA12p = GranSumPA12p + (SumPA12p*100)
      
      GranSumEA1p = GranSumEA1p + (SumEA1p*100)
      GranSumEA2p = GranSumEA2p + (SumEA2p*100)
      GranSumEA3p = GranSumEA3p + (SumEA3p*100)
      GranSumEA4p = GranSumEA4p + (SumEA4p*100)
      GranSumEA5p = GranSumEA5p + (SumEA5p*100)
      GranSumEA6p = GranSumEA6p + (SumEA6p*100)
      GranSumEA7p = GranSumEA7p + (SumEA7p*100)
      GranSumEA8p = GranSumEA8p + (SumEA8p*100)
      GranSumEA9p = GranSumEA9p + (SumEA9p*100)
      GranSumEA10p = GranSumEA10p + (SumEA10p*100)
      GranSumEA11p = GranSumEA11p + (SumEA11p*100)
      GranSumEA12p = GranSumEA12p + (SumEA12p*100)
    End If 
    UltimatePonderacion = CDbl(MatrizApertura(5,k))
    UltimateGranSumPA1p = UltimateGranSumPA1p + (GranSumPA1p*UltimatePonderacion)
    UltimateGranSumPA2p = UltimateGranSumPA2p + (GranSumPA2p*UltimatePonderacion)
    UltimateGranSumPA3p = UltimateGranSumPA3p + (GranSumPA3p*UltimatePonderacion)
    UltimateGranSumPA4p = UltimateGranSumPA4p + (GranSumPA4p*UltimatePonderacion)
    UltimateGranSumPA5p = UltimateGranSumPA5p + (GranSumPA5p*UltimatePonderacion)
    UltimateGranSumPA6p = UltimateGranSumPA6p + (GranSumPA6p*UltimatePonderacion)
    UltimateGranSumPA7p = UltimateGranSumPA7p + (GranSumPA7p*UltimatePonderacion)
    UltimateGranSumPA8p = UltimateGranSumPA8p + (GranSumPA8p*UltimatePonderacion)
    UltimateGranSumPA9p = UltimateGranSumPA9p + (GranSumPA9p*UltimatePonderacion)
    UltimateGranSumPA10p = UltimateGranSumPA10p + (GranSumPA10p*UltimatePonderacion)
    UltimateGranSumPA11p = UltimateGranSumPA11p + (GranSumPA11p*UltimatePonderacion)
    UltimateGranSumPA12p = UltimateGranSumPA12p + (GranSumPA12p*UltimatePonderacion)
    
    UltimateGranSumEA1p = UltimateGranSumEA1p + (GranSumEA1p*UltimatePonderacion)
    UltimateGranSumEA2p = UltimateGranSumEA2p + (GranSumEA2p*UltimatePonderacion)
    UltimateGranSumEA3p = UltimateGranSumEA3p + (GranSumEA3p*UltimatePonderacion)
    UltimateGranSumEA4p = UltimateGranSumEA4p + (GranSumEA4p*UltimatePonderacion)
    UltimateGranSumEA5p = UltimateGranSumEA5p + (GranSumEA5p*UltimatePonderacion)
    UltimateGranSumEA6p = UltimateGranSumEA6p + (GranSumEA6p*UltimatePonderacion)
    UltimateGranSumEA7p = UltimateGranSumEA7p + (GranSumEA7p*UltimatePonderacion)
    UltimateGranSumEA8p = UltimateGranSumEA8p + (GranSumEA8p*UltimatePonderacion)
    UltimateGranSumEA9p = UltimateGranSumEA9p + (GranSumEA9p*UltimatePonderacion)
    UltimateGranSumEA10p = UltimateGranSumEA10p + (GranSumEA10p*UltimatePonderacion)
    UltimateGranSumEA11p = UltimateGranSumEA11p + (GranSumEA11p*UltimatePonderacion)
    UltimateGranSumEA12p = UltimateGranSumEA12p + (GranSumEA12p*UltimatePonderacion)
  Next ' bucle para la variable "k" 
  BigUltimateGranPonderacion = CDBl(MatrizPrograma(5,x))
  BigUltimateGranSumPA1p = BigUltimateGranSumPA1p + (UltimateGranSumPA1p*BigUltimateGranPonderacion)
  BigUltimateGranSumPA2p = BigUltimateGranSumPA2p + (UltimateGranSumPA2p*BigUltimateGranPonderacion)
  BigUltimateGranSumPA3p = BigUltimateGranSumPA3p + (UltimateGranSumPA3p*BigUltimateGranPonderacion)
  BigUltimateGranSumPA4p = BigUltimateGranSumPA4p + (UltimateGranSumPA4p*BigUltimateGranPonderacion)
  BigUltimateGranSumPA5p = BigUltimateGranSumPA5p + (UltimateGranSumPA5p*BigUltimateGranPonderacion)
  BigUltimateGranSumPA6p = BigUltimateGranSumPA6p + (UltimateGranSumPA6p*BigUltimateGranPonderacion)
  BigUltimateGranSumPA7p = BigUltimateGranSumPA7p + (UltimateGranSumPA7p*BigUltimateGranPonderacion)
  BigUltimateGranSumPA8p = BigUltimateGranSumPA8p + (UltimateGranSumPA8p*BigUltimateGranPonderacion)
  BigUltimateGranSumPA9p = BigUltimateGranSumPA9p + (UltimateGranSumPA9p*BigUltimateGranPonderacion)
  BigUltimateGranSumPA10p = BigUltimateGranSumPA10p + (UltimateGranSumPA10p*BigUltimateGranPonderacion)
  BigUltimateGranSumPA11p = BigUltimateGranSumPA11p + (UltimateGranSumPA11p*BigUltimateGranPonderacion)
  BigUltimateGranSumPA12p = BigUltimateGranSumPA12p + (UltimateGranSumPA12p*BigUltimateGranPonderacion)
  
  BigUltimateGranSumEA1p = BigUltimateGranSumEA1p + (UltimateGranSumEA1p*BigUltimateGranPonderacion)
  BigUltimateGranSumEA2p = BigUltimateGranSumEA2p + (UltimateGranSumEA2p*BigUltimateGranPonderacion)
  BigUltimateGranSumEA3p = BigUltimateGranSumEA3p + (UltimateGranSumEA3p*BigUltimateGranPonderacion)
  BigUltimateGranSumEA4p = BigUltimateGranSumEA4p + (UltimateGranSumEA4p*BigUltimateGranPonderacion)
  BigUltimateGranSumEA5p = BigUltimateGranSumEA5p + (UltimateGranSumEA5p*BigUltimateGranPonderacion)
  BigUltimateGranSumEA6p = BigUltimateGranSumEA6p + (UltimateGranSumEA6p*BigUltimateGranPonderacion)
  BigUltimateGranSumEA7p = BigUltimateGranSumEA7p + (UltimateGranSumEA7p*BigUltimateGranPonderacion)
  BigUltimateGranSumEA8p = BigUltimateGranSumEA8p + (UltimateGranSumEA8p*BigUltimateGranPonderacion)
  BigUltimateGranSumEA9p = BigUltimateGranSumEA9p + (UltimateGranSumEA9p*BigUltimateGranPonderacion)
  BigUltimateGranSumEA10p = BigUltimateGranSumEA10p + (UltimateGranSumEA10p*BigUltimateGranPonderacion)
  BigUltimateGranSumEA11p = BigUltimateGranSumEA11p + (UltimateGranSumEA11p*BigUltimateGranPonderacion)
  BigUltimateGranSumEA12p = BigUltimateGranSumEA12p + (UltimateGranSumEA12p*BigUltimateGranPonderacion)
Next ' bucle para la variable "x" 
BigUltimateGranSumPA1p = BigUltimateGranSumPA1p/1000000
BigUltimateGranSumPA2p = BigUltimateGranSumPA2p/1000000
BigUltimateGranSumPA3p = BigUltimateGranSumPA3p/1000000
BigUltimateGranSumPA4p = BigUltimateGranSumPA4p/1000000
BigUltimateGranSumPA5p = BigUltimateGranSumPA5p/1000000
BigUltimateGranSumPA6p = BigUltimateGranSumPA6p/1000000
BigUltimateGranSumPA7p = BigUltimateGranSumPA7p/1000000
BigUltimateGranSumPA8p = BigUltimateGranSumPA8p/1000000
BigUltimateGranSumPA9p = BigUltimateGranSumPA9p/1000000
BigUltimateGranSumPA10p = BigUltimateGranSumPA10p/1000000
BigUltimateGranSumPA11p = BigUltimateGranSumPA11p/1000000
BigUltimateGranSumPA12p = BigUltimateGranSumPA12p/1000000

BigUltimateGranSumEA1p = BigUltimateGranSumEA1p/1000000
BigUltimateGranSumEA2p = BigUltimateGranSumEA2p/1000000
BigUltimateGranSumEA3p = BigUltimateGranSumEA3p/1000000
BigUltimateGranSumEA4p = BigUltimateGranSumEA4p/1000000
BigUltimateGranSumEA5p = BigUltimateGranSumEA5p/1000000
BigUltimateGranSumEA6p = BigUltimateGranSumEA6p/1000000
BigUltimateGranSumEA7p = BigUltimateGranSumEA7p/1000000
BigUltimateGranSumEA8p = BigUltimateGranSumEA8p/1000000
BigUltimateGranSumEA9p = BigUltimateGranSumEA9p/1000000
BigUltimateGranSumEA10p = BigUltimateGranSumEA10p/1000000
BigUltimateGranSumEA11p = BigUltimateGranSumEA11p/1000000
BigUltimateGranSumEA12p = BigUltimateGranSumEA12p/1000000


MesActivo = Session("auth_granted_poa_mes")
If Len(MesActivo) = 0 Then MesActivo = 0 
MesActivo = CInt(MesActivo)

If BigUltimateGranSumPA1p = 0 Then : BigUltimateGranSumEF1 = 0 : Else BigUltimateGranSumEF1 = BigUltimateGranSumEA1p/BigUltimateGranSumPA1p : End If
If BigUltimateGranSumPA2p = 0 Then : BigUltimateGranSumEF2 = 0 : Else BigUltimateGranSumEF2 = BigUltimateGranSumEA2p/BigUltimateGranSumPA2p : End If
If BigUltimateGranSumPA3p = 0 Then : BigUltimateGranSumEF3 = 0 : Else BigUltimateGranSumEF3 = BigUltimateGranSumEA3p/BigUltimateGranSumPA3p : End If
If BigUltimateGranSumPA4p = 0 Then : BigUltimateGranSumEF4 = 0 : Else BigUltimateGranSumEF4 = BigUltimateGranSumEA4p/BigUltimateGranSumPA4p : End If
If BigUltimateGranSumPA5p = 0 Then : BigUltimateGranSumEF5 = 0 : Else BigUltimateGranSumEF5 = BigUltimateGranSumEA5p/BigUltimateGranSumPA5p : End If
If BigUltimateGranSumPA6p = 0 Then : BigUltimateGranSumEF6 = 0 : Else BigUltimateGranSumEF6 = BigUltimateGranSumEA6p/BigUltimateGranSumPA6p : End If
If BigUltimateGranSumPA7p = 0 Then : BigUltimateGranSumEF7 = 0 : Else BigUltimateGranSumEF7 = BigUltimateGranSumEA7p/BigUltimateGranSumPA7p : End If
If BigUltimateGranSumPA8p = 0 Then : BigUltimateGranSumEF8 = 0 : Else BigUltimateGranSumEF8 = BigUltimateGranSumEA8p/BigUltimateGranSumPA8p : End If
If BigUltimateGranSumPA9p = 0 Then : BigUltimateGranSumEF9 = 0 : Else BigUltimateGranSumEF9 = BigUltimateGranSumEA9p/BigUltimateGranSumPA9p : End If
If BigUltimateGranSumPA10p = 0 Then : BigUltimateGranSumEF10 = 0 : Else BigUltimateGranSumEF10 = BigUltimateGranSumEA10p/BigUltimateGranSumPA10p : End If
If BigUltimateGranSumPA11p = 0 Then : BigUltimateGranSumEF11 = 0 : Else BigUltimateGranSumEF11 = BigUltimateGranSumEA11p/BigUltimateGranSumPA11p : End If
If BigUltimateGranSumPA12p = 0 Then : BigUltimateGranSumEF12 = 0 : Else BigUltimateGranSumEF12 = BigUltimateGranSumEA12p/BigUltimateGranSumPA12p : End If

Select Case MesActivo
Case 0 : 
  MesActivoProgramacion = ""	
  MesActivoEjecucion = ""
  MesActivoEficacia = ""
  Mes = ""
Case 1 : 
  MesActivoProgramacion = BigUltimateGranSumPA1p	
  MesActivoEjecucion = BigUltimateGranSumEA1p
  MesActivoEficacia = BigUltimateGranSumEF1*100
  Mes = "Enero"
Case 2 : 
  MesActivoProgramacion = BigUltimateGranSumPA2p	
  MesActivoEjecucion = BigUltimateGranSumEA2p
  MesActivoEficacia = BigUltimateGranSumEF2*100
  Mes = "Febrero"
Case 3 : 
  MesActivoProgramacion = BigUltimateGranSumPA3p	
  MesActivoEjecucion = BigUltimateGranSumEA3p
  MesActivoEficacia = BigUltimateGranSumEF3*100
  Mes = "Marzo"
Case 4 : 
  MesActivoProgramacion = BigUltimateGranSumPA4p	
  MesActivoEjecucion = BigUltimateGranSumEA4p
  MesActivoEficacia = BigUltimateGranSumEF4*100
  Mes = "Abril"
Case 5 : 
  MesActivoProgramacion = BigUltimateGranSumPA5p	
  MesActivoEjecucion = BigUltimateGranSumEA5p
  MesActivoEficacia = BigUltimateGranSumEF5*100
  Mes = "Mayo"
Case 6 : 
  MesActivoProgramacion = BigUltimateGranSumPA6p	
  MesActivoEjecucion = BigUltimateGranSumEA6p
  MesActivoEficacia = BigUltimateGranSumEF6*100
  Mes = "Junio"
Case 7 : 
  MesActivoProgramacion = BigUltimateGranSumPA7p	
  MesActivoEjecucion = BigUltimateGranSumEA7p
  MesActivoEficacia = BigUltimateGranSumEF7*100
  Mes = "Julio"
Case 8 : 
  MesActivoProgramacion = BigUltimateGranSumPA8p	
  MesActivoEjecucion = BigUltimateGranSumEA8p
  MesActivoEficacia = BigUltimateGranSumEF8*100
  Mes = "Agosto"
Case 9 : 
  MesActivoProgramacion = BigUltimateGranSumPA9p	
  MesActivoEjecucion = BigUltimateGranSumEA9p
  MesActivoEficacia = BigUltimateGranSumEF9*100
  Mes = "Septiembre"
Case 10 : 
  MesActivoProgramacion = BigUltimateGranSumPA10p	
  MesActivoEjecucion = BigUltimateGranSumEA10p
  MesActivoEficacia = BigUltimateGranSumEF10*100
  Mes = "Octubre"
Case 11 : 
  MesActivoProgramacion = BigUltimateGranSumPA11p	
  MesActivoEjecucion = BigUltimateGranSumEA11p
  MesActivoEficacia = BigUltimateGranSumEF11*100
  Mes = "Noviembre"
Case 12 : 
  MesActivoProgramacion = BigUltimateGranSumPA12p	
  MesActivoEjecucion = BigUltimateGranSumEA12p
  MesActivoEficacia = BigUltimateGranSumEF12*100
  Mes = "Diciembre"
Case Else : 
  MesActivoProgramacion = BigUltimateGranSumPA12p	
  MesActivoEjecucion = BigUltimateGranSumEA12p
  MesActivoEficacia = BigUltimateGranSumEF12*100
  Mes = "Diciembre"
End Select 	
%>
<link href="Estilos/EstilosPagina.css" rel="stylesheet" type="text/css">
<script src="Scripts/KendoUI/jquery.min.js"></script>
<script src="Scripts/KendoUI/kendo.dataviz.min.js"></script>
<script src="Scripts/KendoUI/console.js"></script>

<table width="400" border="0" cellspacing="1" cellpadding="0" align="center">
  <tr>
      <td>
        
          <table width="50%" border="1" cellspacing="0" cellpadding="0" align="center" bordercolor="#ACACAC" style="border-collapse:collapse;">
                <tr align="center">
                    <td bgcolor="#DBDBDB">Estado</td>
                    <td bgcolor="#DBDBDB"><%=Mes%></td>
                </tr>
                <tr>
                    <td>% Prog. Acumulada</td>
                    <td align="right"><%=Formatnumber(MesActivoProgramacion,2)%> %</td>
                </tr>
                <tr>
                    <td>% Ejec. Acumulada</td>
                    <td align="right"><%=Formatnumber(MesActivoEjecucion,2)%> %</td>
                </tr>
                <tr>
                    <td>Eficacia</td>
                    <td align="right"><strong><%=Formatnumber(MesActivoEficacia,2)%> %</strong></td>
                </tr>
            </table>
        
        </td>
    </tr>
    <tr>
      <td width="345" align="center" valign="middle">
              <div id="gauge-container">
                  <div id="gauge"></div>
              </div>

              <script>
                function createGauge(labelPosition) {
                    $("#gauge").kendoRadialGauge({
                        theme: $(document).data("kendoSkin") || "default",

                        pointer: {
                            value: <%=MesActivoEficacia%>
                        },

                        scale: {
                            minorUnit: 5,
                            startAngle: -30,
                            endAngle: 210,
                            max: 100,
                            labels: {
                                position: labelPosition || "inside"
                            },
                            ranges: [
                                {
                                    from: 0,
                                    to: 75,
                                    color: "#F00"
                                }, {
                                    from: 75,
                                    to: 90,
                                    color: "#FF0"
                                }, {
                                    from: 90,
                                    to: 100,
                                    color: "#060"
                                }
                            ]
                        }
                    });
                }

                $(document).ready(function() {
                    createGauge();

                    $(".configuration").bind("change", refresh);

                    $(document).bind("kendo:skinChange", function(e) {
                        createGauge();
                    });

                    window.configuredRanges = $("#gauge").data("kendoRadialGauge").options.scale.ranges;
                });

                function refresh() {
                    var gauge = $("#gauge").data("kendoRadialGauge"),
                        showLabels = $("#labels").prop("checked"),
                        showRanges = $("#ranges").prop("checked"),
                        positionInputs = $("input[name='labels-position']"),
                        labelsPosition = positionInputs.filter(":checked").val(),
                        options = gauge.options;

                    options.transitions = false;
                    options.scale.labels.visible = showLabels;
                    options.scale.labels.position = labelsPosition;
                    options.scale.ranges = showRanges ? window.configuredRanges : [];

                    gauge.redraw();
                }
              </script>

              <style scoped>
                #gauge-container {
                    background: transparent url("Imagenes/gauge-container1.png") no-repeat 50% 50%;
                    width: 300px;
                    height: 300px;
                    text-align: center;
                 }

                #gauge {
                    width: 245px;
                    height: 245px;
                    margin: 0 auto 0;
                }
              </style>
          
    </td>
    </tr>
</table>
